
<%@ page import="net.iasolution.vendingmachine.constance.VendingConstance"%>
<%@ page import="org.codehaus.groovy.grails.commons.ConfigurationHolder"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <link rel="apple-touch-icon" href="/easyTracker/images/logo-medium.png"/>
    <g:javascript src="jquery-1.5.1.min.js"/>
    <script type="text/javascript" src="http://connect.facebook.net/zh_TW/all.js"></script>
<script type="text/javascript">
   window.fbAsyncInit = function() {
	    FB.init({
	      appId      : '${ConfigurationHolder.config.grails.facebooAppID}', // App ID
	  //    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
	      status     : true, // check login status
	      cookie     : true, // enable cookies to allow the server to access the session
	      xfbml      : true  // parse XFBML
	    });

	    FB.Event.subscribe('auth.authResponseChange', function(response) {
		      alert('response.status = '+ response.status);
	    	  if (response.status === 'connected') {
			    // TODO setting the regiestration form be visibile
			    
	    		  $('#register_frame').show();
			  } else if (response.status === 'not_authorized') {
				  $('#register_frame').hide();
			  } else {
				  //window.location = "/vendingMachine/information/login";
				  window.location =  '${VendingConstance.FACEBOOK_APP_URL}';
			  }
	    });
	  };
</script>
</head>

<body>
<div id="fb-root"></div>
<!-- <fb:login-button data-show-faces="true" data-width="200" data-max-rows="1" scope="publish_stream , offline_access"/> -->
<div name="register_frame" id="register_frame">
<iframe src="https://www.facebook.com/plugins/registration?
             client_id=${ConfigurationHolder.config.grails.facebooAppID}&
             target=_parent&
             redirect_uri=${redirectURL}&
             fields=[
				 {'name':'name'},
				 {'name':'email'},
				 {'name':'location'},
				 {'name':'birthday'},
				 {'name':'phone','description':'Phone Number','type':'text'},
				 {'name':'cardId','description':'Card Number','type':'text'},
				 {'name':'gender'}
		     ]"
        scrolling="auto"
        frameborder="no"
        style="border:none"
        allowTransparency="true"
        width="100%"
        height="500">
</iframe>
</div>
</body>
</html>
